package shangke;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class t2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        //实例化方法
        good d=new good();
        d.setPrice1(180);
        //反射
        Class cla1=Class.forName("shangke.good");
        Field Field= cla1.getField("price1");
            Constructor constructor=cla1.getConstructor();
            Object obj=constructor.newInstance();
             Field.setInt(obj,200);
       Method method= cla1.getMethod("te",int.class);
       int count1=Field.getInt(obj);
       int num1=(int)method.invoke(obj,12);
       //国庆的促销活动
       System.out.println(count1);
       System.out.println(num1);
       //原来的价格
       System.out.println(d.price1);

    }
}
